package org.karelun.gef.figure;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.karelun.gef.helper.ImageResource;

public class ImageNodeFigure extends NodeFigure {
	
	public ImageNodeFigure(){
		setOpaque(false);
		label=new Label();
	}
	
	protected void paintFigure(Graphics graphics) {
		if(isEnabled())
			super.paintFigure(graphics);
		Rectangle full = this.getBounds();
		Image image = ImageResource.getImage(ImageResource.AQ_IMAGE);
		org.eclipse.swt.graphics.Rectangle bound = image.getBounds();
		int x = bound.x;
		int y = bound.y;
		int w = bound.width;
		int h = bound.height;
		Rectangle rect = new Rectangle(x,y,w,h);
		graphics.drawImage(image, rect, full);
		
		Display.getCurrent().timerExec(150, new Runnable(){
			public void run() {
				repaint();
			}
			
		});
	}
	
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		label.setBounds(rect);
	}
	
	protected void setBGColor(Color color) {

	}
}
